#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;
const int maxn=200000, mods=998244353;

ll suf[maxn+1];

class SegmentTree {
	public:
		ll v[4*maxn+1], maxv[4*maxn+1], minv[4*maxn+1];

		void set(int o, int l, int r, int t, int tv) {
			if (l==r) v[o] = maxv[o] = minv[o] = tv;
			else {
				int mid=(l+r)/2;
				if (t<=mid) set(o*2, l, mid, t, tv);
				else set(o*2+1, mid+1, r, t, tv);
				v[o] = v[o*2]+v[o*2+1];
				minv[o] = min(minv[o*2], minv[o*2+1]);
				maxv[o] = max(maxv[o*2], maxv[o*2+1]);
			}
		}

		ll count(int o, int l, int r, ll &sum) {
			if (v[o]<=sum) {
				sum -= v[o];
				return 0;
			} else {
				if (minv[o]>sum) return (suf[r]+mods-suf[l-1])%mods;
				else {
					int mid=(l+r)/2;
					ll ret=0;
					ret = (ret+count(o*2+1, mid+1, r, sum))%mods;
					ret = (ret+count(o*2, l, mid, sum))%mods;
					return ret;
				}
			}
		}
};

int main() {
	freopen("imperishable.in", "r", stdin);
	freopen("imperishable.out", "w", stdout);

	static SegmentTree sgt;
	int num, n, q;
	scanf("%d %d", &num, &n);
	for (int i=1; i<=n; i++) {
		int a;
		scanf("%d", &a);
		sgt.set(1, 1, n, i, a);
	}

	suf[0] = 1;
	for (int i=1; i<=n; i++) suf[i] = suf[i-1]*2%mods;
	suf[0] = 0;
	for (int i=1; i<=n; i++) suf[i] = (suf[i]+suf[i-1])%mods;

	scanf("%d", &q);
	ll temp=sgt.v[1]-sgt.maxv[1];
	printf("%lld\n", sgt.count(1, 1, n, temp));
	for (int i=1; i<=q; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		sgt.set(1, 1, n, x, y);
		temp=sgt.v[1]-sgt.maxv[1];
		printf("%lld\n", sgt.count(1, 1, n, temp));
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
